import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LikePostsVO, LikePostsForm, LikePostsQuery } from '@/api/like/likePosts/types';

/**
 * 查询文章点赞列表
 * @param query
 * @returns {*}
 */

export const listLikePosts = (query?: LikePostsQuery): AxiosPromise<LikePostsVO[]> => {
  return request({
    url: '/like/posts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询文章点赞详细
 * @param likeId
 */
export const getLikePosts = (likeId: string | number): AxiosPromise<LikePostsVO> => {
  return request({
    url: '/like/posts/' + likeId,
    method: 'get'
  });
};

/**
 * 新增文章点赞
 * @param data
 */
export const addLikePosts = (data: LikePostsForm) => {
  return request({
    url: '/like/posts',
    method: 'post',
    data: data
  });
};

/**
 * 修改文章点赞
 * @param data
 */
export const updateLikePosts = (data: LikePostsForm) => {
  return request({
    url: '/like/posts',
    method: 'put',
    data: data
  });
};

/**
 * 删除文章点赞
 * @param likeId
 */
export const delLikePosts = (likeId: string | number | Array<string | number>) => {
  return request({
    url: '/like/posts/' + likeId,
    method: 'delete'
  });
};
